///\todo upgrade

//////////////////////////////////////////////////////////////////////////////////
//                                                                              //
//  This file is part of the buola project (https://code.google.com/p/buola/).  //
//                                                                              //
//  Copyright(c) 2007-2012 Xavi Gratal                                          //
//  gratal AT gmail DOT com                                                     //
//                                                                              //
//  Buola is free software: you can redistribute it and/or modify               //
//  it under the terms of the GNU General Public License as published by        //
//  the Free Software Foundation, either version 3 of the License, or           //
//  (at your option) any later version.                                         //
//                                                                              //
//  Buola is distributed in the hope that it will be useful,                    //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of              //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               //
//  GNU General Public License for more details.                                //
//                                                                              //
//  You should have received a copy of the GNU General Public License           //
//  along with buola.  If not, see <http://www.gnu.org/licenses/>.              //
//                                                                              //
//////////////////////////////////////////////////////////////////////////////////

#ifndef _BUOLA_IMAGE_DATA_H_
#define _BUOLA_IMAGE_DATA_H_

#include <buola/image/format.h>
#include <buola/mat.h>

namespace buola { namespace img {

struct TColorSpace_data
{
    static const size_t cChannels=1;
};

template<typename tData>
struct TChannel_data
{
    typedef tData TType;
    typedef TType TWorkingType;
};

template<typename tData>
struct TFormat_data
{
    static const EImageFormat mID=tData::mImageFormatID;
    typedef TColorSpace_data TColorSpace;
    typedef TChannel_data<tData> TChannel;
    static const std::size_t mPixelSize=sizeof(tData);
};

template<typename tData>
using CImage_data=CImage<TFormat_data<tData>>;
template<typename tData>
using CPixel_data=CPixel<TFormat_data<tData>>;
template<typename tData>
using CView_data=CView<TFormat_data<tData>>;
template<typename tData>
using CMView_data=CMView<TFormat_data<tData>>;

template <>
struct CColorSpaceConversion<TColorSpace_data,TColorSpace_gray>
{
    template <typename tSrc, typename tDst>
    void operator()(const tSrc& pSrc,tDst&& pDst) const
    {
        pDst[0]=pSrc->mPixel[0];
    }
};

#define DECLARE_DATA_IMAGE_TYPES(name,type)                                                                                 \
    typedef ::buola::img::TFormat_data<type> TFormat_##name;                                                                \
    typedef ::buola::img::CImage<TFormat_##name> CImage_##name;                                                             \
    typedef ::buola::img::CPixel<TFormat_##name> CPixel_##name;                                                             \
    typedef ::buola::img::CView<TFormat_##name> CView_##name;                                                               \
    typedef ::buola::img::CMView<TFormat_##name> CMView_##name

/*namespace img*/ } /*namespace buola*/ }

#endif
